package org.go.matchers;

import org.go.util.Key;

/**
 * Matches on group (ignores name) property of Keys.
 *  
 * @author jhouse
 */
public class GroupMatcher<T extends Key> extends StringMatcher<T> {
	/**
	 * 
	 */
	private static final long serialVersionUID = -5961838049970379251L;

	/**
	 * Create a GroupMatcher that matches groups containing the given string.
	 */
	public static GroupMatcher groupContains(String compareTo) {
		return new GroupMatcher(compareTo, StringOperatorName.CONTAINS);
	}

	/**
	 * Create a GroupMatcher that matches groups ending with the given string.
	 */
	public static GroupMatcher groupEndsWith(String compareTo) {
		return new GroupMatcher(compareTo, StringOperatorName.ENDS_WITH);
	}

	/**
	 * Create a GroupMatcher that matches groups equaling the given string.
	 */
	public static GroupMatcher groupEquals(String compareTo) {
		return new GroupMatcher(compareTo, StringOperatorName.EQUALS);
	}

	/**
	 * Create a GroupMatcher that matches groups starting with the given string.
	 */
	public static GroupMatcher groupStartsWith(String compareTo) {
		return new GroupMatcher(compareTo, StringOperatorName.STARTS_WITH);
	}

	protected GroupMatcher(String compareTo, StringOperatorName compareWith) {
		super(compareTo, compareWith);
	}

	@Override
	protected String getValue(T key) {
		return key.getGroup();
	}

}
